__author__ = 'BK'
import utility.bayesUtility
import numpy
from sklearn.naive_bayes import GaussianNB
gnb = GaussianNB()


words=[['my', 'dog', 'has', 'flea', 'problems', 'help', 'please'],
                 ['maybe', 'not', 'take', 'him', 'to', 'dog', 'park', 'stupid'],
                 ['my', 'dalmation', 'is', 'so', 'cute', 'I', 'love', 'him'],
                 ['stop', 'posting', 'stupid', 'worthless', 'garbage'],
                 ['mr', 'licks', 'ate', 'my', 'steak', 'how', 'to', 'stop', 'him'],
                 ['quit', 'buying', 'worthless', 'dog', 'food', 'stupid']]
classes = [0,1,0,1,0,1]

dictionary=utility.bayesUtility.createVocabList(words)

trainM=[]

for i in words:
    trainM.append(utility.bayesUtility.setOfWords2Vec(dictionary,i))

y_pred = gnb.fit(numpy.array(trainM), numpy.array(classes)).predict(trainM)
print y_pred

print("Number of mislabeled points out of a total %d points : %d"
     % (numpy.array(trainM).shape[0],(classes != y_pred).sum()))